package com.fl.util;

import org.quartz.JobKey;
import org.quartz.SchedulerException;
import org.quartz.TriggerKey;

import com.fl.scheduler.FtpTask;
import com.fl.sys.SysConfig;

public class SchedulerUtil {

	public static JobKey getJobKey() {
		return new JobKey(SysConfig.DEF_JOB_NAME, SysConfig.DEF_GROUP_NAME);
	}

	public static TriggerKey getTriggerKey() {
		return new TriggerKey(SysConfig.DEF_TRIGGER_NAME,
				SysConfig.DEF_GROUP_NAME);
	}

	public static boolean isTaskAlive() throws SchedulerException {
		return SysConfig.getSysScheduler().checkExists(getJobKey());
	}

	public static void startTask(String timeRegx) throws Exception {
		new FtpTask().start(timeRegx);
	}

	public static void stopTask() throws Exception {
		SysConfig.getSysScheduler().deleteJob(getJobKey());
	}
}
